﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    /// <summary>
    /// 年龄 组 
    /// </summary>
    public class AgeGroupToColorConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color myColor = (Color)ColorConverter.ConvertFromString("#EDD149");
            SolidColorBrush myBrush = new SolidColorBrush(myColor);
            if (value == null)
            {
                return myBrush;
            }

            AgeGroup status = (AgeGroup)value;

            switch (status)
            {
                case AgeGroup.None:
                    myColor = (Color)ColorConverter.ConvertFromString("#EDD149");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case AgeGroup.Underage:
                    myColor = (Color)ColorConverter.ConvertFromString("#F0911C");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case AgeGroup.Youth:
                    myColor = (Color)ColorConverter.ConvertFromString("#E84118");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;

                case AgeGroup.Middle:
                    myColor = (Color)ColorConverter.ConvertFromString("#E84118");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;

                case AgeGroup.Old:
                    myColor = (Color)ColorConverter.ConvertFromString("#E84118");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;

                default:
                    return myBrush;
            }

        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}